//
//  STORYZJ_TranslateManager.m
//  STORYZJ_App
//
//  Created by zzzzzzzzzz on 2025/9/29.
//

#import "WEEKMO_TranslateManager.h"
//#import <STORYZJ_App-Swift.h>
#import <SpeechAnalyzerDemo-Swift.h>

API_AVAILABLE(ios(18.0))
@interface WEEKMO_TranslateManager()
@property (nonatomic, strong) WEEKMO_SwiftUIFatherView *weekmo_transView;


@property (nonatomic, strong) WEEKMO_TranslateAPIFatherView *weekmo_transAPIView;

@end

@implementation WEEKMO_TranslateManager


+ (instancetype)shareInstance
{
    static WEEKMO_TranslateManager* single;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        single = [[WEEKMO_TranslateManager alloc] init];
    });
    return single;
}




- (WEEKMO_SwiftUIFatherView *)weekmo_transView{
    if (!_weekmo_transView){
        _weekmo_transView = [[WEEKMO_SwiftUIFatherView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
//        _weekmo_transView.hidden = YES;
    }
    return _weekmo_transView;
}

- (WEEKMO_TranslateAPIFatherView *)weekmo_transAPIView API_AVAILABLE(ios(18.0)){
    if (!_weekmo_transAPIView){
        _weekmo_transAPIView = [[WEEKMO_TranslateAPIFatherView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
//        _weekmo_transAPIView.hidden = YES;
    }
    return _weekmo_transAPIView;
}


- (void)weekmo_showSystemTransVCWithOriginalText:(NSString *)originalText withFatherView:(UIView *)view{
    [self.weekmo_transView removeFromSuperview];
    [view addSubview:self.weekmo_transView];
    [view sendSubviewToBack:self.weekmo_transView];
    [self.weekmo_transView uploadTranslateStrWithStr:originalText];
    [self.weekmo_transView showTranslationView];
}


- (void)weekmo_showSystemTransAPIWithOriginalText:(NSString *)originalText withFatherView:(UIView *)view AndResultBlock:(nonnull void (^)(NSString * ,BOOL))weekmo_Resultblock{
    [self.weekmo_transAPIView removeFromSuperview];
    [view addSubview:self.weekmo_transAPIView];
    [view sendSubviewToBack:self.weekmo_transAPIView];
    [self.weekmo_transAPIView uploadTranslateStrWithStr:originalText callBack:weekmo_Resultblock];
}
@end
